<template>
	<view class="mine">
		<view class="mine_top">
			<image :src="content.avater||'../../../static/微信图片_20201124091755.png'" class="top_cover"></image>
			<view class="top_content" @click="Navurl('info')">
				<view class="content_name">{{content.nickname}}</view>
				<!-- <view class="content_adress">浙江·杭州</view> -->
				<view class="content_brief">{{content.introduction==null?'介绍一下自己':content.introduction}}</view>
			</view>
			<image src="../../../static/QRcode_white@2x.png" class="top_ewm" @click="Navurl('ewm')"></image>
		</view>
		<view class="my_order">
			<view class="order_title" @click="$linkTo('/pagesB/myorder/myorder')">
				<view class="title_left">
					我的订单
				</view>
				<view class="title_right">
					全部订单
				</view>
				<view class="line"></view>
			</view>
			<view class="order_content">
				<!-- <view class="grid" index="2">
					<image src="/static/icondingdan_daifukuan@2x(1).png" mode=""></image>
				    <text class="text">待发货</text>
					<uni-badge v-if="content.order_count.wait_delivery_count!=0" type="error" size="small" :text="content.order_count.wait_delivery_count"></uni-badge>
				</view>
				<view class="grid" index="2">
					<image src="/static/icondingdan_daifukuan@2x(1).png" mode=""></image>
				    <text class="text">待发货</text>
					<uni-badge v-if="content.order_count.wait_delivery_count!=0" type="error" size="small" :text="content.order_count.wait_delivery_count"></uni-badge>
				</view>
				<view class="grid" index="2">
					<image src="/static/icondingdan_daifukuan@2x(1).png" mode=""></image>
				    <text class="text">待发货</text>
					<uni-badge v-if="content.order_count.wait_delivery_count!=0" type="error" size="small" :text="content.order_count.wait_delivery_count"></uni-badge>
				</view>
				<view class="grid" index="2">
					<image src="/static/icondingdan_daifukuan@2x(1).png" mode=""></image>
				    <text class="text">待发货</text>
					<uni-badge v-if="content.order_count.wait_delivery_count!=0" type="error" size="small" :text="content.order_count.wait_delivery_count"></uni-badge>
				</view>
				<view class="grid" index="2">
					<image src="/static/icondingdan_daifukuan@2x(1).png" mode=""></image>
				    <text class="text">待发货</text>
					<uni-badge v-if="content.order_count.wait_delivery_count!=0" type="error" size="small" :text="content.order_count.wait_delivery_count"></uni-badge>
				</view> -->
				<uni-grid :column="5" :show-border="false"  :square="false"  @change="Tourl()">
				    <uni-grid-item index="1">
						<image src="/static/icondingdan_daifukuan@2x.png" mode=""></image>
				        <text class="text">待付款</text>
						<uni-badge v-if="content.order_count.wait_pay_count!=0" type="error" size="small" :text="content.order_count.wait_pay_count"></uni-badge>
				    </uni-grid-item>
					<uni-grid-item index="2">
						<image src="/static/icondingdan_daifukuan@2x(1).png" mode=""></image>
					    <text class="text">待发货</text>
						<uni-badge v-if="content.order_count.wait_delivery_count!=0" type="error" size="small" :text="content.order_count.wait_delivery_count"></uni-badge>
					</uni-grid-item>
					<uni-grid-item index="3">
						<image src="../../../static/icondingdan_daifukuan@2x(2).png" mode=""></image>
					    <text class="text">待收货</text>
						<uni-badge v-if="content.order_count.wait_receive_count!=0" type="error" size="small" :text="content.order_count.wait_receive_count"></uni-badge>
					</uni-grid-item>
					<uni-grid-item index="4">
						<image src="../../../static/icondingdan_daifukuan@2x(3).png" mode=""></image>
					    <text class="text">待评价</text>
						<uni-badge v-if="content.order_count.wait_comment_count!=0" type="error" size="small" :text="content.order_count.wait_comment_count"></uni-badge>
					</uni-grid-item>
					<uni-grid-item index="5">
						<image src="../../../static/icondingdan_daifukuan@2x(4).png" mode=""></image>
					    <text class="text">退款/付款</text>
						<uni-badge v-if="content.order_count.wait_refund_count!=0" type="error" size="small" :text="content.order_count.wait_refund_count"></uni-badge>
					</uni-grid-item>
				</uni-grid>
			</view>
		</view>
		<view class="my_order">
			<view class="order_title spokesman" @click="tospokes">
				<view class="title_left">
					我是代言人
				</view>
				<view class="title_right ">
					如何成为代言人
				</view>
				<view class="line"></view>
			</view>
			<view class="order_content spokesprice">
				<uni-grid :column="3" :show-border="false"  :square="false">
					<uni-grid-item class="mg_20">
						<view class="num">{{dataList.commission||'0.00'}}</view>
					    <text class="text">累计奖励</text>
					</uni-grid-item>
					<uni-grid-item class="mg_20 bor">
						<view class="num">{{dataList.sale_amount||'0.00'}}</view>
					    <text class="text">累计销售</text>
					</uni-grid-item>
					<uni-grid-item class="mg_20">
						<view class="num">{{dataList.fans_count||'0.00'}}</view>
					    <text class="text">粉丝数</text>
					</uni-grid-item>
					<uni-grid-item>
						<view class="num">{{content.spokesman_today.commission||'0.00'}}</view>
					    <text class="text">今日奖励</text>
					</uni-grid-item>
					<uni-grid-item class="bor">
						<view class="num">{{content.spokesman_today.today_sale||'0.00'}}</view>
					    <text class="text">今日销售</text>
					</uni-grid-item>
					<uni-grid-item>
						<view class="num">{{content.spokesman_today.today_fans||'0.00'}}</view>
					    <text class="text">今日新增</text>
					</uni-grid-item>
				</uni-grid>
			</view>
		</view>
		<view class="my_order">
			<view class="order_title" @click="$linkTo('/pagesB/news/news')">
				<view class="line"></view>
				<view class="title_left">
					消息
				</view>
				<view class="title_right">
					<uni-badge v-if="num!=0" type="error" size="small" :text="num"></uni-badge>
				</view>
			</view>
			<view class="order_title" @click="$linkTo('/pagesB/coups/coups')" v-if="couponConfig">
				<view class="line"></view>
				<view class="title_left">
					{{couponConfig.coupon_title}}
				<image class="title_icon" :src="couponConfig.coupon_icon"></image>
				</view>
				<view class="title_right">
					
				</view>
			</view>
			<view class="order_title" @click="$linkTo('/pages/spokesman/My_account')">
				<view class="line"></view>
				<view class="title_left">
					我的账户
				</view>
				<view class="title_right">
					
				</view>
			</view>
			<view class="order_title" @click="$linkTo('/pagesA/haibao/haibao')">
				<view class="line"></view>
				<view class="title_left">
					直播
				</view>
				<view class="title_right">
					
				</view>
			</view>
			<view class="order_title" @click="article">
				<view class="line"></view>
				<view class="title_left">
					我的文章
				</view>
				<view class="title_right">
					
				</view>
			</view>
			<navigator url="/pagesB/collection/collection" class="order_title">
				<view class="line"></view>
				<view class="title_left">
					商品收藏
				</view>
				<view class="title_right">
					查看全部
				</view>
			</navigator>
			<view class="Collection_content">
						<view class="Collection_item" v-for="(item,index) in content.collections" :key="index" @click="Details(item.goods_id)">
							<image :src="item.cover" mode=""></image>
							<view class="Collection_title">{{item.name}}</view>
							<view class="Collection_price">￥{{item.price}}</view>
						</view>
				</uni-grid>
			</view>
		</view>
		<view class="my_order">
			<view class="order_title" @click="$linkTo('/pagesB/Feedback/Feedback')">
				<view class="line"></view>
				<view class="title_left">
					意见反馈
				</view>
				<view class="title_right ">
					
				</view>
			</view>
			<view class="order_title" @click="setup">
				<view class="line"></view>
				<view class="title_left">
					设置
				</view>
				<view class="title_right ">
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import md5 from '@/common/api/md5.js'
	import uniBadge from "@/components/uni-badge/uni-badge.vue"
	import uniGrid from "@/components/uni-grid/uni-grid.vue"
	import uniGridItem from "@/components/uni-grid-item/uni-grid-item.vue"
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	import {requestUrl} from '@/common/config.js'
	export default{
		components: {uniGrid,uniGridItem,uniBadge, uniPopup,
        uniPopupMessage,
        uniPopupDialog},
		data(){
			return{
				Access_token:'',
				content:[],
				dataList:'',
				num:'',
				couponConfig:[]
			}
		},
		onShow() {
			if(uni.getStorageSync('access_token')){
			this.access_token=JSON.parse(uni.getStorageSync('access_token'))
			}else{
				uni.showModal({
				    title: '提示',
				    content: '你还未登录，请先登录',
				    success: function (res) {
				        if (res.confirm) {
							uni.navigateTo({
								url:'/pages/login/login'
							})
				        } else if (res.cancel) {
				        }
				    }
				});
			}
			this.$request('/app/user/getUserInfo','post',{
				access_token:JSON.parse(uni.getStorageSync('access_token'))
			}).then(res=>{
				console.log(res)
				if(res.errcode==0){
					this.content=res.content
					console.log(this.content)
				}else{
					uni.showModal({
					    title: '提示',
					    content: res.message,
					    success: function (res) {
					        if (res.confirm) {
								uni.navigateTo({
									url:"/pages/login/login"
								})
					        } else if (res.cancel) {
								console.log(222)
					        }
					    }
					});
				}
			})
			this.$request('/app/setting/couponConfig','post',{
				access_token:JSON.parse(uni.getStorageSync('access_token'))
			}).then(res=>{
				this.couponConfig=res.content
			})
			this.$request('/app/user/spokesman','post',{
				access_token:JSON.parse(uni.getStorageSync('access_token'))
			}).then(res=>{
				this.dataList=res.content
			})
			this.$request('/app/message/getMessages','post',{
				access_token:JSON.parse(uni.getStorageSync('access_token'))
			}).then(res=>{
				console.log(res)
				this.num=Number(res.content.system_count)+Number(res.content.order_count)+Number(res.content.fans_count)+Number(res.content.reply_count)+Number(res.content.attention_count)+Number(res.content.like_count)
				// this.num=res.content.system_count
				console.log(this.num)
			})
		},
		methods:{
			Details(e){
				// uni.setStorage({
				//     key: 'goods_id',
				//     data: JSON.stringify(e),
				//     success: function () {
				//     }
				// });
				uni.navigateTo({
				    url: '/pagesA/CommodityDetails/CommodityDetails?goods_id='+e
				});
			},
			tospokes(){
				console.log(1)
				uni.switchTab({
					url:'/pages/spokesman/spokesman'
				})
			},
			setup(){
				uni.navigateTo({
					// url:'/pages/mine/mine/setup/setup'
					url:'/pagesB/setup/setup'
				})
			},
			article(){
				uni.navigateTo({
					url:'/pagesB/myarticle/myarticle'
				})
			},
			feedback(){
				uni.navigateTo({
					// url:'/pages/mine/mine/Feedback/Feedback'
					url:'/pagesB/Feedback/Feedback'
				})
			},
			Tourl(e){
				if(e.detail.index==5){
					uni.navigateTo({
						// url:'/pages/mine/mine/myorder/refund'
						url:'/pagesB/myorder/refund'
					})
				}else{
					uni.navigateTo({
						// url:'/pages/mine/mine/myorder/myorder',
						url:'/pagesB/myorder/myorder?id='+e.detail.index
					})
				}
			},
			Navurl(e){
				if(e=='ewm'){
					uni.navigateTo({
						// url:'/pages/mine/mine/ewm/ewm'
						url:'/pagesB/ewm/ewm'
					})
				}else if(e=='info'){
					uni.navigateTo({
						// url:'/pages/mine/mine/information/information'
						url:'/pagesB/information/information'
					})
				}
			}
		}

	}
</script>

<style lang="less" scoped>
	page {
		height: 100%;
	}
	.mine {
		background-color: #F3F4F5;
		height: 100%;
		overflow-y: scroll;
		.mine_top{
			display: flex;
			padding: 40rpx;
			margin-bottom: 20rpx;
			background-color: #fff;
			.top_cover{
				width: 180rpx;
				height: 180rpx;
				margin-right: 32rpx;
			}
			.top_content{
				flex: 1;
				margin: auto;
				.content_name{
					font-size: 36rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 50rpx;
				}
				.content_adress{
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 36rpx;
				}
				.content_brief{
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 36rpx;
				}
			}
			.top_ewm{
				width: 40rpx;
				height: 40rpx;
				margin: auto;
			}
		}
		.my_order{
			background: #fff;
			margin-bottom: 20rpx;
			.order_title{
				display: flex;
				justify-content: space-between;
				padding: 20rpx 40rpx;
				position: relative;
				background: url(@/static/direction_right_gray.png)no-repeat 690rpx 25rpx ;
				background-size: 28rpx 28rpx;
				.line{
					position: absolute;
					bottom: 0;
					left: 0;
					height: 1px;
					  width: 100%;
					  background-color: #dddddd;
					  transform-origin: 0 0;
					  transform: scale(1, 0.4);
					}
				.title_left{
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
					    display: flex;
					    align-items: center;
				}
				.title_icon{
					width: 30rpx;
					height: 30rpx;
					margin: auto;
					margin-left: 10rpx;
				}
				.title_right{
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #9DA5A8;
					padding-right: 30rpx;
				}
			}
			.spokesman{
				background: url(@/static/goods_how.png)no-repeat 690rpx 22rpx;
				background-size: 28rpx 28rpx;
			}

			.order_content{
				padding: 30rpx 0;
				box-sizing: border-box;
				uni-grid-item {
					position: relative;
					uni-badge{
						position: absolute ;
						right: 14rpx;
						top: -8rpx;
					}
					/deep/.uni-grid-item__box {
						display: flex;
						flex-flow: column;
						justify-content: center;
						align-items: center;
				
					}
				image{
					width: 60rpx;
					height: 60rpx;
				}
				.num{
					font-size: 32rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #111111;
				}
				.text{
					font-size: 22rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
				}
				}


			}
			.spokesprice{
				uni-grid-item {
					margin: 0 15rpx;
				}
				/deep/.uni-grid-item{
				width: 220rpx !important;
				}
				.num{
					margin-bottom: 10rpx;
				}
				.text{
					font-size: 22rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #9DA5A8 !important;
				}
				.bor{
					border-left: 1rpx solid #E8E8E8;
					border-right: 1rpx solid #E8E8E8;
				}
				.mg_20{
					margin-bottom: 40rpx;
				}
			}
			.Collection_content{
				display: flex;
				// justify-content: space-around;
				padding: 20rpx 0;
				margin-bottom: 20rpx;
				overflow-x: scroll;
				.Collection_item{
					width: 220rpx;
					margin: 0 10rpx;
				}
				image{
					width: 220rpx;
					height: 220rpx;
				}
				.Collection_title{
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #111111;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
				}
				.Collection_price{
					font-size: 28rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #DB1B22;
				}
			}
		}
		}
</style>
